﻿using System;

namespace DflyingForum.Core.Data.NHHelper
{
    public class CriteriaParameter
    {
        private string _propertyName;
        private string _table;
        private object _value1;
        private object _value2;
        private object[] _values;
        private CriteriaOperator _criteriaOperator;

        public CriteriaParameter(string propertyName, object value1, CriteriaOperator criteriaOperator)
            : this(propertyName, value1, null, null, criteriaOperator, "") { }

        /// <summary>
        /// 只能用来排序
        /// </summary>
        public CriteriaParameter(string propertyName, CriteriaOperator criteriaOperator)
            : this(propertyName, null, null, null, criteriaOperator, "") { }

        public CriteriaParameter(string propertyName, object value1, object value2, CriteriaOperator criteriaOperator)
            : this(propertyName, value1, value2, null, criteriaOperator, "") { }

        /// <summary>
        /// 关联查询
        /// </summary>
        public CriteriaParameter(string propertyName, object value1, CriteriaOperator criteriaOperator, string table)
            : this(propertyName, value1, null, null, criteriaOperator, table) { }



        public CriteriaParameter(string propertyName, object value1, object value2, object[] values, CriteriaOperator criteriaOperator, string table)
        {
            this._table = table;
            this._propertyName = propertyName;
            this._value1 = value1;
            this._value2 = value2;
            this._values = values;
            this._criteriaOperator = criteriaOperator;
        }

        public string PropertyName
        {
            get { return _propertyName; }
            set { _propertyName = value; }
        }
        public object Value1
        {
            get { return _value1; }
            set { _value1 = value; }
        }
        public object Value2
        {
            get { return _value2; }
            set { _value2 = value; }
        }
        public object[] Values
        {
            get { return _values; }
            set { _values = value; }
        }

        public string Table
        {
            get { return _table; }
            set { _table = value; }
        }

        public CriteriaOperator CriteriaOperator
        {
            get { return _criteriaOperator; }
            set { _criteriaOperator = value; }
        }
    }

    public enum CriteriaOperator
    {
        Eq = 1,
        Gt = 2,
        Lt = 3,
        Between = 4,
        Like = 5,
        In = 6,
        NotIn = 16,
        On = 7,
        IsNotNullOrEmpty = 8,
        IsNullOrEmpty = 9,
        Or = 10,//怎么实现？
        Le = 11,
        Ge = 12,
        NotEq = 13,
        OrderByDesc = 14,
        OrderByAsc = 15
    }
}
